/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tabuvpr.model;

import java.util.ArrayList;
import tabuvpr.main.Tabuparameters;

/**
 *
 * @author Shadow
 */
public class Solucion {

    ArrayList<Vehiculo> _vehiculos;
    
    Solucion(ArrayList<Vehiculo> vehiculos) {
        _vehiculos = vehiculos;
    }

    Solucion() {
        _vehiculos = new ArrayList<>();
    }

    public boolean isEmpty(){
        return _vehiculos.isEmpty();
    }
    public int size(){
        return _vehiculos.size();
    }
    public Vehiculo get(int index){
        return _vehiculos.get(index);
    }
    
    public double getCost() {
        double costo = 0;
        for(Vehiculo vehiculo : _vehiculos){
            costo += vehiculo.getRuta().getCosto() * Tabuparameters.getCostoVehiculo(vehiculo.getTipoVehiculo());
        }
        return costo;
    }
    
    public double getMinX(){
        double minX = Double.MAX_VALUE;
        for (Vehiculo vehiculo:_vehiculos){
            for (int i = 0; i < vehiculo.getRuta().size();i++){
                Node nodo = vehiculo.getRuta().get(i);
                if (nodo.getX() < minX)
                    minX = nodo.getX();
            }
        }
        return minX;
    }
    public double getMinY(){
        double minY = Double.MAX_VALUE;
        for (Vehiculo vehiculo:_vehiculos){
            for (int i = 0; i < vehiculo.getRuta().size();i++){
                Node nodo = vehiculo.getRuta().get(i);
                if (nodo.getY() < minY)
                    minY = nodo.getY();
            }
        }
        return minY;
    }
    public double getMaxX(){
        double maxX = Double.MIN_VALUE;
        for (Vehiculo vehiculo:_vehiculos){
            for (int i = 0; i < vehiculo.getRuta().size();i++){
                Node nodo = vehiculo.getRuta().get(i);
                if (nodo.getX() > maxX)
                    maxX = nodo.getX();
            }
        }
        return maxX;
    }
    public double getMaxY(){
        double maxY = Double.MIN_VALUE;
        for (Vehiculo vehiculo:_vehiculos){
            for (int i = 0; i < vehiculo.getRuta().size();i++){
                Node nodo = vehiculo.getRuta().get(i);
                if (nodo.getY() > maxY)
                    maxY = nodo.getY();
            }
        }
        return maxY;
    }
    
    public void add(Vehiculo v){
        _vehiculos.add(v);
    }
}
